package com.zxy.express.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhangxiying
 * @date 2022/3/17 18:09
 */
@Configuration
@Slf4j
public class HeaderFilter implements Filter {

    @Override
    public void destroy() {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        HttpServletResponse resp = (HttpServletResponse) response;
        //允许前端获取date属性
        resp.setHeader("Access-Control-Expose-Headers", "date");
        chain.doFilter(request, response);

    }
}